package wsz.sharding.algorithm;

import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.core.strategy.keygen.SnowflakeShardingKeyGenerator;
import org.apache.shardingsphere.spi.keygen.ShardingKeyGenerator;

import java.util.Properties;

/**
 * 自定义id生成
 * @author wsz
 * @desc：
 * @date 2022/6/8
 */
@Slf4j
public class CommonKey implements ShardingKeyGenerator {
    private SnowflakeShardingKeyGenerator snow = new SnowflakeShardingKeyGenerator();

    @Override
    public Comparable<?> generateKey() {
        log.info("执行了自定义主键生成器CommonKey");
        return snow.generateKey();
    }

    @Override
    public String getType() {
        return "COMMONKEY";
    }

    @Override
    public Properties getProperties() {
        return null;
    }

    @Override
    public void setProperties(Properties properties) {

    }
}
